﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EstimationStudio.Core;

namespace EstimationStudio.UI
{
    public partial class AdjustmentFactorControl : UserControl
    {
        public AdjustmentFactorControl()
        {
            InitializeComponent();
        }

        public event EventHandler Changed;

        private AdjustmentFactor AdjustmentFactor { get; set; }

        private void AdjustmentVariabilityControl_Changed(object sender, EventArgs e)
        {
            if (Changed != null)
                Changed(this, EventArgs.Empty);
        }

        public void LoadAdjustmentFactor(AdjustmentFactor adjustmentFactor)
        {
            if (adjustmentFactor == null)
                return;

            AdjustmentFactor = adjustmentFactor;
            lblName.Text = adjustmentFactor.Name;
            lblDescription.Text = adjustmentFactor.Description;
            AdjustmentVariabilityControl.SetAdjustmentVariability(adjustmentFactor.AdjustmentVariability, adjustmentFactor.CurrentRating);
        }

        public AdjustmentFactor UnloadAdjustmentFactor()
        {
            AdjustmentFactor.CurrentRating = AdjustmentVariabilityControl.GetCurrentRating();
            AdjustmentFactor.AdjustmentVariability = AdjustmentVariabilityControl.GetAdjustmentVariability();
            return AdjustmentFactor;
        }
    }
}
